<!--
 * @Author: 张定勇 zhangdingyong@mi-ya.com.cn
 * @Date: 2025-05-17 18:12:24
 * @LastEditors: 张定勇 zhangdingyong@mi-ya.com.cn
 * @LastEditTime: 2025-05-19 09:43:42
 * @FilePath: /code/components/ucFoot.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view class="c-footer">
    <view class="c-list">
      <view
        class="item"
        v-for="(item, index) in list"
        :key="index"
        @click="btnGo"
        :data-url="item.pagePath"
        :class="index == props.selectIndex ? 'on' : ''"
      >
        <image
          :src="index == props.selectIndex ? item.selectedIconPath : item.iconPath"
          mode="widthFix"
          class="uc-icon50"
        ></image>
        {{ item.text }}
      </view>
    </view>
  </view>
  <view class="c-footer-space">
    <view class="footer-space"></view>
  </view>
</template>
<script setup>
import { ref } from 'vue';
const props = defineProps({
  selectIndex: {
    type: Number,
    default: 0
  }
});
const list = ref([
  {
    pagePath: '/pages/home/home',
    iconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft1.png',
    selectedIconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft1-on.png',
    text: '名片'
  },
  {
    pagePath: '/pages/shop/shop',
    iconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft2.png',
    selectedIconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft2-on.png',
    text: '商城'
  },
  {
    pagePath: '/pages/dynamics/dynamics',
    iconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft3.png',
    selectedIconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft3-on.png',
    text: '动态'
  },
  {
    pagePath: '/pages/site/site',
    iconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft4.png',
    selectedIconPath: 'https://v.uicut.com/xcx-temp2025/20250513/ft4-on.png',
    text: '官网'
  }
]);
const btnGo = (e) => {
  var url = e.currentTarget.dataset.url;
  var pages = getCurrentPages();
  var page = '/' + pages[pages.length - 1].route;
  if (page != url) {
    uni.redirectTo({ url: url });
  }
};
</script>
